#!/bin/bash
# wait-for-it.sh

set -e

host="$1"
port="$2"
shift 2
cmd="$@"

until nc -z -v -w30 "$host" "$port"; do
  echo "等待 $host:$port 就绪..."
  sleep 2
done

echo "$host:$port 已就绪，开始执行命令"
exec $cmd 